package com.jiai.base.config;


import com.jiai.live.dto.LiveDto;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by qudingyi on 2017/5/2.
 */
public class OnLineLiveCache {
    private static Map<Long,LiveDto> onLineLive=new ConcurrentHashMap<Long,LiveDto>();

    public static  void  addLive(Long roomId,LiveDto live){
            onLineLive.putIfAbsent(roomId,live);
    }

    public   static void remove(Long roomId){
            onLineLive.remove(roomId);
    }
    public static LiveDto getByRoomId(Long roomId){
            return onLineLive.get(roomId);
    }

    public  static  List<LiveDto> getAll(){
        List<LiveDto>  datas=new ArrayList<>();
        for(Map.Entry<Long,LiveDto> e: onLineLive.entrySet() ){
            datas.add(e.getValue());

        }
        return datas;
    }

}
